home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / fse / uuencode.fse < prev   
Text File  |  1998-05-24  |  3KB  |  114 lines

  1. /* UUEncode.fse by Troels Walsted Hansen
  2. ** $VER: UUEncode.fse 1.00 (1.11.94)
  3. **
  4. ** An ARexx script that uuencodes a file and imports it into
  5. ** the FSE you are currently using. Unless the file is already
  6. ** archived this script will optionally do it for you (using LhA).
  7. **
  8. ** Utilises LhA by Stefan Boberg and either of the following:
  9. **    · UUFast v1.25 by Jørn Halonen
  10. **    · uuIn v1.03 by Nicolas Dade
  11. **    · UUxT v3.0 by Asher Feldman
  12. */
  13.  
  14. /* some user variables. edit to your hearts content */
  15.  
  16. tmpdir = "T:"        /* Work dir for the encoding    */
  17. uuencoder = "uuin"    /* may be: uuin, uufast or uuxt */
  18.  
  19. /* needs FSE, THOR and bbsread.library functions */
  20.  
  21. options results
  22.  
  23. if(substr(address(),1,8) ~= "THOR_FSE") then
  24. do
  25.     say "This script should only be started from inside the FSE."
  26.     exit 20
  27. end
  28. else fseport = address()
  29.  
  30. p = ' ' || address() || ' ' || show('P',,)
  31. thorport = pos(' THOR.',p)
  32.  
  33. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  34. else
  35. do
  36.     say 'No THOR port found!'
  37.     exit 10
  38. end
  39.  
  40. if ~show('p', 'BBSREAD') then
  41. do
  42.     address command
  43.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  44.         "WaitForPort BBSREAD"
  45. end
  46.  
  47. /* get filename */
  48.  
  49. address(bbsread)
  50. GETGLOBALDATA STEM GLOBALDATA
  51.  
  52. address(thorport)
  53. THORTOFRONT
  54. REQUESTFILE TITLE '"Select file to encode:"' ID '"'GLOBALDATA.UPLOADPATH'"' FP PAT '"#?"'
  55. if(rc ~= 0) then exit
  56.  
  57. filetoencode = result
  58. lastchar = right(filetoencode,1)
  59.  
  60. if(lastchar = "/" | lastchar = ":" | filetoencode = "") then
  61. do
  62.     REQUESTNOTIFY TEXT '"No file selected!"' BT '"_Ok"'
  63.     call CleanUp()
  64. end
  65.  
  66. posi = lastpos("/",FileToEncode)
  67. if(posi = 0) then posi = lastpos(":",FileToEncode)
  68. WithoutPath = substr(FileToEncode,posi+1)
  69.  
  70. /* if file isn't LhA'ed -- do it ourselves */
  71.  
  72. extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
  73.  
  74. if~(extension = "LHA" | extension = "LZH") then
  75. do
  76.     REQUESTNOTIFY TEXT '"Do you want to LhA the file?"' BT '"_Yes|_No"'
  77.     if(result) then
  78.     do
  79.         address command "LhA >nil: -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
  80.  
  81.         if(rc ~= 0) then REQUESTNOTIFY TEXT '"LhA''ing did not succeed."' BT '"_Ok"'
  82.         else FileToEncode = tmpdir||WithoutPath||".lha"
  83.     end
  84. end
  85.  
  86. select
  87.     when(uuencoder = 'uufast') then cmd = "UUFast >nil: " || '"' || filetoencode || '"' || " TO " || tmpdir || "Message.uu E"
  88.     when(uuencoder = 'uuin') then cmd = "uuIn >nil: INFILE=" || '"' || filetoencode || '"' || " OUTFILE=" || tmpdir || "Message.uu"
  89.     when(uuencoder = 'uuxt') then cmd = 'UUxT >nil: a ' || tmpdir || 'Message.uu ' || '"'filetoencode'"'
  90.     otherwise
  91.     do
  92.         REQUESTNOTIFY TEXT '"UUEncoder not configured correctly."' BT '"_Ok"'
  93.         call CleanUp()
  94.     end
  95. end
  96. address command cmd
  97.  
  98. if ~exists(tmpdir"Message.uu") then
  99. do
  100.     REQUESTNOTIFY TEXT '"Something went wrong during uuencoding."' BT '"_Ok"'
  101.     call CleanUp()
  102. end
  103.  
  104. address(fseport)
  105. INCLUDEFILE tmpdir"Message.uu"
  106.  
  107. /* cleanup and exit */
  108.  
  109. CleanUp:
  110.     if(exists(tmpdir || WithoutPath || ".lha")) then address command 'delete >nil: ' || '"' || tmpdir || WithoutPath || '.lha' || '"'
  111.     if(exists(tmpdir || "Message.uu")) then address command 'delete >nil: ' || tmpdir || 'Message.uu'
  112.     exit
  113. return
  114.